package com.shengyi.mapper;

import com.shengyi.model.CarFinance;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

@Mapper
public interface CarFinanceMapper {
    @Insert("INSERT INTO car_finance(income,expend) " +
            "VALUES(#{finance.income},#{finance.expend})")
    public Integer insertFinance(@Param("finance") CarFinance carFinance);

    @Update("UPDATE car_finance SET income = (income + #{income}),expend = (expend + #{expend}) WHERE date(create_time) = CURDATE()  ")
    public Integer updateFinance(@Param("income") Double income,@Param("expend") Double expend);

    @Select("SELECT income,expend,create_time createTime FROM car_finance WHERE create_time>=#{start} AND create_time<=#{end}")
    public List<CarFinance> selectFinanceByTime(@Param("start") Date start, @Param("end")Date end);
}
